package com.tangchao.client.sdh.view.selectColor
{
	import com.tangchao.client.sdh.definition.DFCardColor;
	import com.tangchao.client.sdh.event.SelectColorEvent;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.ui.Mouse;
	import flash.ui.MouseCursor;

	public class BaseColor extends MovieClip
	{
		private var _color:int=DFCardColor.COLOR_NONE;
		private var _back:MovieClip;
		
		private var _parentUI:SelectColorPanel;
		
		public function BaseColor()
		{
			_back=getChildByName("mcBack") as MovieClip;
			_back.stop();
			addEventListener(MouseEvent.CLICK,onMouseClick);
			addEventListener(MouseEvent.MOUSE_OVER,onMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT,onMouseOut);
		}
		
		public function set parentUI(ui:SelectColorPanel):void
		{
			_parentUI = ui;
		}
		
		/*
		*选择某种花色
		*/
		private function onMouseClick(e:MouseEvent)
		{
			backState=3;
			if(_parentUI)
			{
				_parentUI.onSelectColor(_color, x, y);
			}
//			var evt:SelectColorEvent=new SelectColorEvent();
//			evt.color=_color;
//			dispatchEvent(evt);
		}
		
		private function onMouseOver(e:MouseEvent)
		{
			backState=2;
			Mouse.cursor = MouseCursor.BUTTON;
		}
		
		private function onMouseOut(e:MouseEvent)
		{
			Mouse.cursor = MouseCursor.AUTO;
			backState=1;
		}
		
		public function set color(value:int)
		{
			_color=value;
		}
		
		public function get color()
		{
			return _color;
		}
		
		public function set backState(i:int)
		{
			//_back.gotoAndStop(i);
		}
	}
}